package com.integrance.budgetapp.util;

import java.io.FileOutputStream;
import java.sql.Connection;
import java.sql.DriverManager;

import org.dbunit.database.DatabaseConnection;
import org.dbunit.database.IDatabaseConnection;
import org.dbunit.dataset.xml.FlatDtdDataSet;

public class DatabaseSchemaExport {
	public static void main(String[] args) throws Exception {
		// database connection
		Class.forName("org.hsqldb.jdbcDriver");
		Connection jdbcConnection = DriverManager.getConnection(
				"jdbc:hsqldb:hsql://localhost:9005/budgetapp", "sa", "");
		
		IDatabaseConnection connection = new DatabaseConnection(jdbcConnection);

		// write DTD file
		FlatDtdDataSet.write(connection.createDataSet(), new FileOutputStream("schema.dtd"));
	}

}
